package com.example;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;
import de.greenrobot.daogenerator.ToMany;

public class ExampleDaoGenerator
{

    public static void main(String[] args) throws Exception
    {
        Schema schema = new Schema(1, "greendao");
        addNote(schema);
        new DaoGenerator().generateAll(schema,
                "E:\\AndroidStudioWorkSpace\\AppWuhan\\app\\src\\main\\java-greendao");
    }
    private static void addLoreDetail(Schema schema)
    {
        Entity loreDetail = schema.addEntity("LoreDetailTable");

        loreDetail.addIdProperty();

        loreDetail.addStringProperty("title").notNull().unique();

        loreDetail.addStringProperty("imageUrl").notNull();

        loreDetail.addLongProperty("time");

    }

    /**
     * @param schema
     */
    private static void addNote(Schema schema)
    {
        Entity note = schema.addEntity("DetailTable");
        note.setTableName("NoteTable");
        note.addIdProperty().primaryKey().autoincrement();
        note.addStringProperty("picUrl");
        note.addStringProperty("title");
        note.addLongProperty("time");
    }

    private static void addCustomerOrder(Schema schema)
    {
        Entity customer = schema.addEntity("Customer");
        customer.addIdProperty();
        customer.addStringProperty("name").notNull();

        Entity order = schema.addEntity("Order");
        order.setTableName("ORDERS");

        order.addIdProperty();
        Property orderDate = order.addDateProperty("date").getProperty();
        Property customerId = order.addLongProperty("customerId").notNull().getProperty();
        order.addToOne(customer, customerId);

        ToMany customerToOrders = customer.addToMany(order, customerId);
        customerToOrders.setName("orders");
        customerToOrders.orderAsc(orderDate);
    }
}
